package cn.tedu.charging.order.mqtt;

import cn.tedu.charging.order.dao.mapper.OrderFailMapper;
import cn.tedu.charging.order.dao.mapper.OrderSuccessMapper;
import cn.tedu.charging.order.dao.repository.ChargingProcessRepository;
import cn.tedu.charging.order.dao.repository.OrderRepository;
import cn.tedu.charging.order.feign.CostClient;
import cn.tedu.charging.order.feign.UserClient;
import cn.tedu.charging.order.websocket.WebSocketServer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 封装MqttConsumer要用到的在容器里的对象
 */
@Component  //被容器管理 把mapper注入进来
public class MqttContext {
    /*
    @Autowired
    private OrderSuccessMapper orderSuccessMapper;

    @Autowired
    private OrderFailMapper orderFailMapper;

    //进入MqttConsumer后，要拿出来，加个get方法
    public OrderSuccessMapper getOrderSuccessMapper() {
        return orderSuccessMapper;
    }

    public OrderFailMapper getOrderFailMapper() {
        return orderFailMapper;
    }

     */

    //8.5 dao层解耦，不直接调用mapper
    @Autowired
    private OrderRepository orderRepository;

    public OrderRepository getOrderRepository() {
        return orderRepository;
    }

    //10.2 让订单能将设备发送过来的充电进度，同步给计价服务
    @Autowired
    private CostClient costClient;

    public CostClient getCostClient() {
        return costClient;
    }

    //12.3 MqttConsumer中要检查用户余额，需要给context里先注入userClient
    @Autowired
    private UserClient userClient;

    public UserClient getUserClient() {
        return userClient;
    }

    //12.4 MqttConsumer中用这个，使用ES保存时序数据
    @Autowired
    private ChargingProcessRepository chargingProcessRepository;

    public ChargingProcessRepository getChargingProcessRepository() {
        return chargingProcessRepository;
    }

    //13.1 要和用户通信，推送充电数据给用户
    @Autowired
    private WebSocketServer webSocketServer;

    public WebSocketServer getWebSocketServer() {
        return webSocketServer;
    }
}
